package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.xcity.db.entity.Player;
import com.xcity.game.employee.EmployeeService;
import com.xcity.game.employee.config.impl.EmployeeQualityLevelUpConfigure;
import com.xcity.game.employee.config.impl.EmployeeQualityLevelUpConfigure.QualityUpgradable;
import com.xcity.game.employee.response.EmployeeLevelUpRequired;
import com.xcity.game.employee.template.EmployeeQualityUpTemplate;
import com.xcity.game.item.ItemInfo;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class EmployeeQualityUpInfoResponse extends Response {
	
	private long id;
	private int qualityLvl; // 品级
	private int qualityMaxLvl;
	private int levelLimit; // 等级限制
	private List<ItemInfo> items = Collections.emptyList(); // 升品需求物品
	private long gold; // 需求现金
	
	public EmployeeQualityUpInfoResponse(int serial, Player player, QualityUpgradable unit, EmployeeService service) {
		super(serial);
		this.id = unit.getId();
		this.qualityLvl = unit.getQualityLevel();
		EmployeeQualityLevelUpConfigure configure = service.configure().getQualityLevelUpConfigure();
		this.qualityMaxLvl = configure.getMaxLevel(unit);
		EmployeeQualityUpTemplate template = configure.getNextLevelTemplate(unit);
		if (template != null) {
			this.levelLimit = template.getLevelLimit();
			ItemInfo[] refers = template.getWrappedItems();
			this.items = new ArrayList<ItemInfo>(refers.length);
			for (ItemInfo refer : refers) {
				this.items.add(new EmployeeLevelUpRequired(refer, player));
			}
			this.gold = template.getGold();
		}
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getQualityLvl() {
		return qualityLvl;
	}

	public void setQualityLvl(int qualityLvl) {
		this.qualityLvl = qualityLvl;
	}

	public int getQualityMaxLvl() {
		return qualityMaxLvl;
	}

	public void setQualityMaxLvl(int qualityMaxLvl) {
		this.qualityMaxLvl = qualityMaxLvl;
	}

	public int getLevelLimit() {
		return levelLimit;
	}

	public void setLevelLimit(int levelLimit) {
		this.levelLimit = levelLimit;
	}

	public List<ItemInfo> getItems() {
		return items;
	}

	public void setItems(List<ItemInfo> items) {
		this.items = items;
	}

	public long getGold() {
		return gold;
	}

	public void setGold(long gold) {
		this.gold = gold;
	}
	
}
